﻿

namespace EasyStep.TestActions.WebAii
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using ArtOfTest.WebAii.Core;
    using EasyStep.Business.Interfaces;
    using EasyStep.TestExecution.Data;
    using EasyStep.TestExecution.Interfaces;
    using EasyStep.TestExecution.Browsers;
    using System.Drawing;

    public class InternetExplorer : BaseWebBrowserProxy<Manager>
    {
        public InternetExplorer() : base("InternetExplorer", "InternetExplorer.png", "") { }

        public override object GetNewInstance(IExecuteDataContext context)
        {
            var manager = new Manager(BrowserHelper.GetBrowserSettings(this.Name, BrowserType.InternetExplorer));
            manager.Start();
            manager.LaunchNewBrowser();
            return manager;
        }
        public override Image MakeScreenshot(IExecuteDataContext DataContext, TestStepResult data)
        {
            return BrowserHelper.MakeScreenshot(DataContext, data);
        }
        public override void FinalizeInstance(object data)
        {
            var manager = data as Manager;
            if (manager == null) return;
            if (manager.Browsers != null)
            foreach (var item in manager.Browsers)
            {
                item.Close(500);
                manager.RemoveBrowser(item.ClientId);
            }
            manager.Dispose();
            manager = null;
        }
    }

    
}
